const { databaseContext } = require('../config/database.config');
const { Sequelize } = require('sequelize');
const UserModel = require('../model/user')
const TagsModel = require('../model/tags')
const DairyModel = require('../model/dairy')
const sequelize = new Sequelize({
    ...databaseContext
})


async function bootstrap() {
    try {
        await sequelize.authenticate();
        console.log('Connection has been established successfully.');
      } catch (error) {
        console.error('Unable to connect to the database:', error);
    }
}
bootstrap()
UserModel.init(sequelize)
TagsModel.init(sequelize)
DairyModel.init(sequelize)
sequelize.sync().then(() => {
    console.log('数据库同步成功')
})
module.exports = {
    sequelize
}